*Replication data for Owsiak, Andrew P., K. Michael Greig, and Paul F. Diehl. 2021. Making Trains from Boxcars: Studying Conflict and Conflict Management Interdependencies. International Interactions (special issue introduction).

*Stata 15
use "Data.dta.", clear

*Table A1. Correlation Analysis
corr primarythirdpartyrole unilateralmultilateral  inpartialbiased lowhighcost consensualinvoluntary nohighcoercion fulllowprocesscontrol fulllowoutcomecontrol shortlongtermengagement shortlongtermgoals integrativedistributive easyhardtorepeat

*Run a series of different models, varying the number of dimensions. Watch for change in loss criterion (i.e., stress value).
*Based on correlation analysis, we drop nohighcoercion and shortlongtermengagement.
mds primarythirdpartyrole integrativedistributive consensualinvoluntary fulllowprocesscontrol fulllowoutcomecontrol  inpartialbiased shortlongtermgoals lowhighcost unilateralmultilateral easyhardtorepeat, id(strategyname) method(modern) measure(gower) initial(classical) dimension(1)

mds primarythirdpartyrole integrativedistributive consensualinvoluntary fulllowprocesscontrol fulllowoutcomecontrol  inpartialbiased shortlongtermgoals lowhighcost unilateralmultilateral easyhardtorepeat, id(strategyname) method(modern) measure(gower) initial(classical) dimension(2)

mds primarythirdpartyrole integrativedistributive consensualinvoluntary fulllowprocesscontrol fulllowoutcomecontrol  inpartialbiased shortlongtermgoals lowhighcost unilateralmultilateral easyhardtorepeat, id(strategyname) method(modern) measure(gower) initial(classical) dimension(3)

mds primarythirdpartyrole integrativedistributive consensualinvoluntary fulllowprocesscontrol fulllowoutcomecontrol  inpartialbiased shortlongtermgoals lowhighcost unilateralmultilateral easyhardtorepeat, id(strategyname) method(modern) measure(gower) initial(classical) dimension(4)

mds primarythirdpartyrole integrativedistributive consensualinvoluntary fulllowprocesscontrol fulllowoutcomecontrol  inpartialbiased shortlongtermgoals lowhighcost unilateralmultilateral easyhardtorepeat, id(strategyname) method(modern) measure(gower) initial(classical) dimension(5)

*Moving from a model with three to four dimensions does not reduce the loss criterion significantly further. Three dimensions therefore becomes the model we use.

*Figure 2. 
mds primarythirdpartyrole integrativedistributive consensualinvoluntary fulllowprocesscontrol fulllowoutcomecontrol  inpartialbiased shortlongtermgoals lowhighcost unilateralmultilateral easyhardtorepeat, id(strategyname) method(modern) measure(gower) initial(classical) dimension(3)
*From this, derive the three dimensional point coordinates. 
estat config
* extract these point coordinates and save data to another file "X3d_plot_data.dta", for use in 3d graphing.

* use "kappa data.dta"
* This appears in a footnote. It involves coefficients of agreement among the editors as coders of the twelve characteristics.
* Rows of the data matrix are the twelve characteristics.
* x1 x2 x3 = The three editors' individual codings of each strategy (editor 1, editor 2, editor 3), before reconciled.
kap neg1 neg2 neg3
kap med1 med2 med3
kap arb1 arb2 arb3
kap adj1 adj2 adj3
kap pk1 pk2 pk3
kap pb1 pb2 pb3
kap san1 san2 san3
kap int1 int2 int3

*To create the 3d graph, must move to R. This was done in RStudio. 
*install.packages("plot3D")
library(haven)
X3d_plot_data <- read_dta("3d plot data.dta")
library("plot3D")
View(X3d_plot_data)
x<-X3d_plot_data$dim
y<-X3d_plot_data$dim2
z<-X3d_plot_data$dim3
scatter3D(x, y, z, phi=0, bty = "g", type = "h", pch = 19, cex = 0.5)
scatter3D(x, y, z, phi=0, theta= 330, bty = "g", type = "h", pch = 19, cex = 0.5, col = "black", xlab = "First Dimension", ylab = "Second Dimension", zlab = "Third Dimension", n=2, colkey = FALSE, plotdev(xlim = c(-1, 1), ylim = c(-1, 1), zlim = c(-1, 1)))
text3D(x,y,z, labels = X3d_plot_data$type, add = TRUE, colkey = FALSE, cex = 1)
